#include<bits/stdc++.h>

using namespace std;

int n,l,r;

int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	int rl,rr;
	rl = l/n;
	rr = r/n;
	l%=n;
	r%=n;
	if(l<r){
		cout<<r<<endl;
	}
	else if(l>r){
		cout<<n-1<<endl;
	}
	else{
		if(rl<rr){
			cout<<n-1<<endl;
		}
		else{
			cout<<l<<endl;
		}
	}
	return 0;
}
